<?php
// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
//    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));

defined('CAPTCHA_PATH')
    || define('CAPTCHA_PATH', realpath(dirname(__FILE__) . '/captcha'));

defined('CAPTCHA_IMG_REFER_PATH')
    || define('CAPTCHA_IMG_REFER_PATH', '/captcha/');

define('WINDOWS_ENV', 'windows');
// define('LINUX_ENV', 'linux');
define('VIDEO_PREFIX', '/vod/');
define('THUMBNAILS_PREFIX', '/thumbnails/');
defined('LINUX_ENV') && define('VIDEO_PATH', '/home/xiaopei/www/videostudy/public/vod/');
defined('LINUX_ENV') && define('THUMBNAILS_PATH', '/home/xiaopei/www/videostudy/public/thumbnails/');
defined('LINUX_ENV') && define('FFMPEG', '/usr/local/bin/ffmpeg');
defined('WINDOWS_ENV') && define('VIDEO_PATH', 'E:\\AppServ\\www\\videostudy\\public\\vod\\');
defined('WINDOWS_ENV') && define('THUMBNAILS_PATH', 'E:\\AppServ\\www\\videostudy\\public\\thumbnails\\');
defined('WINDOWS_ENV') && define('FFMPEG', 'ffmpeg.exe');
    
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

date_default_timezone_set('Asia/Shanghai');

require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);

function myErrorHandler($errno, $errstr, $errfile, $errline)
{
  printf("%d: %s, %s, %d<br/>", $errno, $errstr, $errfile, $errline);
}
//set_error_handler("myErrorHandler");

Zend_Session::setOptions(array('strict'=>true));

/** Zend_Application */
require_once 'Zend/Application.php';
include('global.php');

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
header("Content-type: text/html; charset=utf-8");
$application->bootstrap()
            ->run();
